package com.itheima.prince.smartpeking.base;

import android.content.Context;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.TextView;

import com.itheima.prince.smartpeking.R;
import com.itheima.prince.smartpeking.activity.MainActivity;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;

/**
 * Created by Prince on 2016/10/20.
 */
public abstract class BasePager {
    //提供子类使用
    protected Context mcontext;
    //提供外界直接调用
    public View rootView;
    protected TextView mtitle;
    protected ImageButton mmenu;
    protected FrameLayout mcontent;
    protected ImageButton mGvOrLv;

    public BasePager(Context context) {
        this.mcontext=context;
        rootView =initview();
    }

    protected View initview(){
        View view = View.inflate(mcontext,R.layout.pager_basepager,null);
        mtitle = (TextView) view.findViewById(R.id.tv_basepager_title);
        mmenu = (ImageButton) view.findViewById(R.id.ib_basepager_menu);
        mcontent = (FrameLayout) view.findViewById(R.id.fl_basepager_content);
        mGvOrLv = (ImageButton) view.findViewById(R.id.ib_photos_gridorlist);
        mmenu.setOnClickListener(new MyOnClickListener());
        return view;
    };

    //可以实现，也可以不实现；
    public void initdata(){

    }

    class MyOnClickListener implements View.OnClickListener {

        @Override
        public void onClick(View view) {
            MainActivity mainActivity = (MainActivity) mcontext;
            SlidingMenu slidingMenu = mainActivity.getSlidingMenu();
            slidingMenu.toggle();

        }
    }
}
